home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / TOOLS.ZIP / MANEXT.C < prev    next >
Text File  |  1992-11-21  |  4KB  |  130 lines

  1. /***********************************************************************/
  2. /* MANEXT - Extract manual pages from C source code.                   */
  3. /***********************************************************************/
  4. /*
  5.  * MANEXT - A program to extract manual pages from C source code.
  6.  * Copyright (C) 1991,1992 Mark Hessling
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License as
  10.  * published by the Free Software Foundation; either version 2 of
  11.  * the License, or any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to:
  20.  *
  21.  *    The Free Software Foundation, Inc.
  22.  *    675 Mass Ave,
  23.  *    Cambridge, MA 02139 USA.
  24.  *
  25.  *
  26.  * If you make modifications to this software that you feel increases
  27.  * it usefulness for the rest of the community, please email the
  28.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  29.  * This software is going to be maintained and enhanced as deemed
  30.  * necessary by the community.
  31.  *
  32.  * Mark Hessling                     email: M.Hessling@itc.gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 7877
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38. #include <stdio.h>
  39.  
  40. void display_info();
  41.  
  42. #define MAX_LINE 255
  43.  
  44. /***********************************************************************/
  45. int main(argc,argv)
  46. int argc;
  47. char *argv[];
  48. /***********************************************************************/
  49. {
  50.  char    s[MAX_LINE + 1];        /* input line */
  51.  register int     i = 0;
  52.  FILE *fp;
  53.  char c;
  54.  char append=0;
  55.  
  56.  if (strcmp(argv[1],"-h") == 0)
  57.    {
  58.     display_info();
  59.     exit(1);
  60.    }
  61.  for(i=1;i<argc;i++)
  62.     {
  63.      if ((fp = fopen(argv[i],"r")) == NULL)
  64.        {
  65.         fprintf(stderr,"\nCould not open %s\n",argv[i]);
  66.         continue;
  67.        }
  68.      while(1)
  69.        {
  70.         if (fgets(s, (int)sizeof(s), fp) == NULL)
  71.           {
  72.           if (ferror(fp) != 0)
  73.              {
  74.               fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  75.               exit(1);
  76.              }
  77.           break;
  78.           }
  79.  
  80.         /* check for manual entry marker at beginning of line */
  81.         if (strncmp(s, "/*man-start*", 12) != 0)
  82.             continue;
  83.  
  84.         /* inner loop */
  85.         for (;;)
  86.            {
  87.             /* read next line of manual entry */
  88.            if (fgets(s, (int)sizeof(s), fp) == NULL)
  89.               {
  90.               if (ferror(fp) != 0)
  91.                 {
  92.                  fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  93.                  exit(1);
  94.                 }
  95.                break;
  96.              }
  97.            /* check for end of entry marker */
  98.            if (strncmp(s, "**man-end", 9) == 0)
  99.               break;
  100.  
  101.            printf("     %s",s);
  102.             }
  103.        printf("\n\n\n     --------------------------------------------------------------------------\n");
  104.  
  105.         /* check if end of file */
  106.         if (feof(fp) != 0)
  107.             break;
  108.        }
  109.      fclose(fp);
  110.     }
  111.  printf("\n\n\n\n\n");
  112.  return(0);
  113. }
  114. /***********************************************************************/
  115. void display_info()
  116. /***********************************************************************/
  117. {
  118. /*--------------------------- local data ------------------------------*/
  119. /*--------------------------- processing ------------------------------*/
  120.  
  121.  fprintf(stderr,"\nMANEXT 1.00 Copyright (C) 1991,1992 Mark Hessling\n");
  122.  fprintf(stderr,"All rights reserved.\n");
  123.  fprintf(stderr,"MANEXT is distributed under the terms of the GNU\n");
  124.  fprintf(stderr,"General Public License and comes with NO WARRANTY.\n");
  125.  fprintf(stderr,"See the file COPYING for details.\n");
  126.  fprintf(stderr,"\nUsage: MANEXT sourcefile [...]\n\n");
  127.  fflush(stderr);
  128.  return;
  129. }
  130.